%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Module summary
%%
%% Main authors: 
%% Progress to usefulness: 
%%
%% A chord worker supervisor.
%%
%% Chord workers are spawned when someone 
%% requested a lookup, and dies when the work is done.
%% 
%%%%%%%%%%%%%%%%%%%%%%%

-module(chord_worker_sup).
-behaviour(supervisor).
-include("db.hrl").
% OTP interface
-export([start_link/0]).
-export([init/1]).
-export([start_worker/1]).

% OTP
start_link() ->
    io:format("Starting Chord worker Supervisor\n"),
    supervisor:start_link({local, ?MODULE}, ?MODULE, []).

init(_Args) ->
    {ok, {{simple_one_for_one, 0, 60},
          [{chord_worker, {chord_worker, start_link, []},
           temporary, 5000, worker, [chord_worker]}]}}.

start_worker(State) ->
    supervisor:start_child(?MODULE, [State]).
